<?php
/**
 * Created by PhpStorm.
 * User: Frings
 * Date: 2016/9/18
 * Time: 11:17
 */

use yii\helpers\Url;

$web = Url::base();
?>
<?php
if ($list != null && $list != '') {
    for ($i = 0; $i < count($list); $i++) {
        ?>
        <tr class='<?php
        if (strlen($list[$i]['parent_code']) / 2 == 1) {
            echo $list[$i]['parent_code'];
        } else if (strlen($list[$i]['parent_code']) / 2 == 2) {
            echo substr($list[$i]['parent_code'], 0, 2) . ' ' . $list[$i]['parent_code'];
        }
        ?>'>
            <td>
                <?php if (strlen($list[$i]['code']) / 2 != 3) {
                    ?>
                    <img src="<?= $web ?>/images/mall/details_open.png"
                         style="margin-top: 10px;margin-left: <?php echo 5 + (strlen($list[$i]['code']) / 2 - 1) * 25 ?>px"
                         data-type="open"
                         onclick="getChildGoodsCategory(this,'<?php echo $list[$i]['code'] ?>')">
                    <?php
                }
                ?>
            </td>
            <td>
                <?php
                echo strlen($list[$i]['code']) / 2
                ?>
            </td>
            <td>
                <a href="javascript:void(0)" class="tooltips" rel="<?= $list[$i]['image_url'] ?>"
                   target="_blank">
                    <img src="<?= $list[$i]['image_url'] ?>" style="width: 3rem; height: 3rem;">
                </a>
            </td>
            <td><?= $list[$i]['name'] ?></td>
            <td><?php if($list[$i]['is_show']==1) echo '是'; else echo '否'; ?></td>
            <!--                            <td>--><?//= $list[$i]['parent_code'] ?><!--</td>-->
            <td>
                <div class="btn-group">
                    <?php
                    if (strlen($list[$i]['code']) / 2 != 3) {
                        ?>
                        <button class="btn btn-link btn-xs" type="button"
                                onclick="addCate('<?= $list[$i]['code'] ?>','<?= $list[$i]['name'] ?>')"
                                data-toggle="modal"
                                data-target="#myModalGoodsCategoryEdit">
                            添加下级
                        </button>
                        <?php
                    }
                    ?>
                    <button class="btn btn-link btn-xs" type="button"
                            onclick="editCate('<?= $list[$i]['code'] ?>','<?= $list[$i]['name'] ?>','<?= $list[$i]['is_show'] ?>','<?= $list[$i]['image_url'] ?>','<?= $list[$i]['parent_code'] ?>','<?= $list[$i]['institution_code'] ?>')"
                            data-toggle="modal"
                            data-target="#myModalGoodsCategoryEdit">
                        修改
                    </button>
                    <button class="btn btn-link btn-xs" type="button"
                            data-toggle="modal"
                            data-target="#deleteModal"
                            onclick="delData('<?= $list[$i]['code'] ?>','<?= $list[$i]['institution_code'] ?>')">
                        删除
                    </button>
                </div>
            </td>
        </tr>
        <?php
    }
}
?>

